package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.XzkcServiceljc;
import com.zr.serviceImpl.XzkcServiceImplljc;

public class XzkcControllerljc extends HttpServlet{
	//新增课程控制器
	XzkcServiceljc xs = new XzkcServiceImplljc();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		PrintWriter pw =resp.getWriter();
		String cname = req.getParameter("cname");
		String classtime = req.getParameter("classtime");
		String place = req.getParameter("place");
		String tname = req.getParameter("tname");
		int tid = xs.findTeacheridBytname(tname).getTid();
		boolean flag = xs.insertCourse(cname, classtime, place, tid);
		if(flag){
			pw.write("1");
		}else{
			pw.write("0");
		}	
	pw.flush();
	pw.close();
	}
}
